<?php

namespace app\common\model\question;

use app\common\model\Model;
use traits\model\SoftDelete;

class Category extends Model
{

    use SoftDelete;


    // 表名
    protected $name = 'question_category';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [

    ];

    const VIP_M = 'm';
    const VIP_Q = 'q';
    const VIP_Y = 'y';

    const VIP = [
        self::VIP_M => '月度',
        self::VIP_Q => '季度',
        self::VIP_Y => '年度',
    ];

    public function getVipAttr($value)
    {
        return $value ? json_decode($value, true) : (object)[];
    }

    public function setVipAttr($value)
    {
        return json_encode($value);
    }

    public function setExamAttr($value)
    {
        return json_encode($value);
    }

    public function getExamAttr($value)
    {
        return $value ? json_decode($value, true) : (object)[];
    }
}
